package edu.uestc.canary.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebApplicationConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*") //允许跨域的请求的url
                .allowedMethods("GET","POST","PUT","DELETE") //允许跨域的请求方法
                .allowedHeaders("*") //请求头
                .allowCredentials(true); //是否允许携带跨域cookie凭证
    }
}
